/*
 * CAI.java
 * 
 * Copyright (c) 2009 Giles Millward (Manigra). All rights reserved.
 * 
 * This file is part of Expression program is undefined on line 8, column 40 in Templates/Licenses/license-gplv3.txt..
 * 
 * Expression program is undefined on line 10, column 19 in Templates/Licenses/license-gplv3.txt. is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Expression program is undefined on line 15, column 19 in Templates/Licenses/license-gplv3.txt. is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Expression program is undefined on line 21, column 30 in Templates/Licenses/license-gplv3.txt..  If not, see <http://www.gnu.org/licenses/>.
 */

package dpssystem;

import dpsinterface.CDPSAbilityAction;
import java.util.ArrayList;
import playstyle.CAbilityType.Ability;

/**
 *
 * @author Mani
 */
public class CAI {
    CSim m_sim;

    // Abstracts
    ArrayList<CAbility> m_finisherActionList= new ArrayList<CAbility>();
    ArrayList<CDPSAbilityAction> m_finisherControlList;
    
    CAbility m_builderAction = null;
    CDPSAbilityAction m_builderControl = null;
    boolean m_aFinisherHasFocus = false;

    CAI(CSim p_sim)
    {
        m_sim = p_sim;
    }

    // Link simulation abilities to our playstyle ability controllers
    void linkAbilities()
    {
        // Link up the list to local one for this class (maybe performance improvement)
        Ability l_ability;;

        for (int i = 0; i < 0; i++)
        {
            l_ability = m_finisherControlList.get(i).m_abilityType;
            if (l_ability == Ability.RUPTURE)
            {
                m_finisherActionList.add(m_sim.m_rupture);
            } else if (l_ability == Ability.ENVENOM)
            {
                m_finisherActionList.add(m_sim.m_envenom);
            } else if (l_ability == Ability.EVISCERATE)
            {
                m_finisherActionList.add(m_sim.m_eviscerate);
            } else if (l_ability == Ability.SLICE_AND_DICE)
            {
                m_finisherActionList.add(m_sim.m_player.m_sliceAndDice);
            } else if (l_ability == Ability.SINISTER_STRIKE)
            {
                m_builderAction = m_sim.m_sinisterStrike;
            } else if (l_ability == Ability.MUTILATE)
            {
                m_builderAction = m_sim.m_mutilate;
            } else if (l_ability == Ability.HEMORRHAGE)
            {
                m_builderAction = m_sim.m_stubAbility;
            } else if (l_ability == Ability.BACKSTAB)
            {
                m_builderAction = m_sim.m_stubAbility;
            } else if (l_ability == Ability.SHIV)
            {
                m_builderAction = m_sim.m_stubAbility;
            }
        }
    }

    void processAI()
    {
        // TODO Check 'On Use' trinkets
        // TODO Check CD abilities
        hackyAI();
        
    }

    // Hacky AI to get the simulation to do things it probably shouldn't
    void hackyAI()
    {
        // Testing mutilate attack
        if (m_sim.m_gcd.endOfGCD())
        {

            if (m_sim.m_target.m_comboPoints.m_comboPoints > 0 &&
                    m_sim.m_currentRunTime < m_sim.m_player.m_sliceAndDice.m_endOfTimer &&
                    m_sim.m_currentRunTime > m_sim.m_player.m_sliceAndDice.m_endOfTimer - 2)
            {
                if (m_sim.m_envenom.canExecute())
                {
                    m_sim.m_envenom.execute();
                }
            }

            if (m_sim.m_currentRunTime > m_sim.m_player.m_sliceAndDice.m_endOfTimer)
            {
                // Slice n Dice is not active
                if (m_sim.m_target.m_comboPoints.m_comboPoints > 0)
                {
                    // Get it running regardless of combo points
                    if (m_sim.m_player.m_sliceAndDice.canExecute())
                    {
                        m_sim.m_player.m_sliceAndDice.execute();
                    }
                }
            }

            if (m_sim.m_target.m_comboPoints.m_comboPoints >= 4)
            {
                if (m_sim.m_rupture.canExecute())
                {
                    m_sim.m_rupture.execute();
                }
            }

            if (m_sim.m_target.m_comboPoints.m_comboPoints >= 4)
            {
                if (m_sim.m_envenom.canExecute())
                {
                    m_sim.m_envenom.execute();
                }
            }

            if (m_sim.m_mutilate.canExecute())
            {
                m_sim.m_mutilate.execute();
            }
        }
    }
}
